$(function () {
    $("#jqGrid").jqGrid({
        url: baseURL + 'sys/statis/allStatistics',
        datatype: "json",
        colModel: [
            { label: '书籍ID', name: 'bookid', index: "bookIid", width: 45, key: true },
            { label: '书籍名称', name: 'bookname', width: 75 },
            { label: '销售额(元)', name: 'rewardMoney', width: 90 ,formatter: function (value, options, row) {
                return value / 100}
            },
            { label: '来源', name: 'source', width: 90}
        ],
        viewrecords: true,
        height: 385,
        rowNum: 10,
        rowList : [10,30,50],
        rownumbers: true,
        rownumWidth: 25,
        autowidth: true,
        multiselect: true,
        pager: "#jqGridPager",
        jsonReader : {
            root: "page.records",
            page: "page.current",
            total: "page.pages",
            records: "page.total"
        },
        prmNames : {
            page:"page",
            rows:"limit",
            order: "order"
        },
        gridComplete:function(){
            //隐藏grid底部滚动条
            $("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
        }
    });
});

var vm = new Vue({
    el:'#rrapp',
    data:{
        q:{
            bookname: null
        },
        showList: true,
    },
    methods: {
        query: function () {
            vm.reload();
        },
        reload: function () {
            vm.showList = true;
            var page = $("#jqGrid").jqGrid('getGridParam','page');
            $("#jqGrid").jqGrid('setGridParam',{
                postData:{'bookname': vm.q.bookname},
                page:page
            }).trigger("reloadGrid");
        }
    }
});